package com.qiche.service.impl;

import com.qiche.mapper.CarVehicleMapper;
import com.qiche.mapper.ComboDetailMapper;
import com.qiche.model.CarVehicle;
import com.qiche.model.ComboDetail;
import com.qiche.service.ComboDetailService;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Linzw on 2018/01/24.
 */
@Service("comboDetailService")
public class ComboDetailServiceImpl extends BaseService<ComboDetail> implements ComboDetailService{

    @Resource
    private ComboDetailMapper comboDetailMapper;

    @Override
    public List<ComboDetail> selectByMasterId(Integer masterId){
        Example example = new Example(ComboDetail.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("masterId",masterId);
        return comboDetailMapper.selectByExample(example);
    }
    @Override
    public int batchInsert(List<ComboDetail> comboDetailList){
       return comboDetailMapper.insertList(comboDetailList);
    }

    @Override
    public int batchDeleteByDetailIds(List<Integer> deleteIdList){
        Example example = new Example(ComboDetail.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andIn("id",deleteIdList);
        return comboDetailMapper.deleteByExample(example);
    }

    @Override
    public int batchDeleteByMasterId(Integer masterId){
        Example example = new Example(ComboDetail.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("masterId",masterId);
        return comboDetailMapper.deleteByExample(example);
    }
}
